import request from "./request";

let route = 'http://farmer.handsomesunshine.com';

// 获取首页商品
export function goodsInfo(activity=1) {
  return request({
    url:`${route}/api/homeactivity?activity=${activity}`
  })
}

// 获取商品详情
export function goodsDetail(goods_id_alias='2osxwo20inibs') {
  return request({
    url:`${route}/api/goodsdetail?goodsId=${goods_id_alias}`
  })
}

// 搜索商品
export function searchGoods(value) {
  return request({
    url:`${route}/api/goodssearch?value=${value}`
  })
}

// 获取用户购物车数据
export function shopcarData() {
  return request({
    url:`${route}/api/shopcardata`
  })
}

export function removeShopcar (goodsId) {
  return request({
    url: `${route}/api/removeshopcar`,
    method: 'POST',
    data: {
      goodsId:JSON.stringify(goodsId)
    }
  })
}

export function updateShopcar (goods) {
  return request({
    url: `${route}/api/updateshopcar`,
    method: 'POST',
    data: {
      goods
    }
  })
}

//商品评论
export function fetchAppraise(goods_id) {
  return request({
    url:`${route}/api/comments?goods_id=${goods_id}`
  })
}

// 评论类型
export function fetchCommentsType(goods_id,type) {
  return request({
    url:`${route}/api/commentstype?goods_id=${goods_id}&type=${type}`
  })
}